package com.study.langchain4j.api.rag;

import com.study.langchain4j.service.rag.EmbeddingModelService;
import org.springframework.web.bind.annotation.*;

/**
 * @author xl-9527
 * @since 2025/11/3
 */
@RestController
@RequestMapping("ai/embedding/model")
public class EmbeddingModelApi {

    private final EmbeddingModelService embeddingModelService;

    public EmbeddingModelApi(final EmbeddingModelService embeddingModelService) {
        this.embeddingModelService = embeddingModelService;
    }

    @GetMapping("/to-vector")
    public Object toVector(@RequestParam("text") String text) {
        return embeddingModelService.toVector(text).vectorAsList();
    }

    @PostMapping("/write-to-vector-database")
    public void writeToVectorDataBase(@RequestParam("content") String content) {
        embeddingModelService.writeToVectorDataBase(content);
    }
}
